<?php

namespace App\Models\client;

use App\Models\AdminModel;
use App\Models\airline\base\RouteModel;
use App\Models\base\CurrencyModel;
use App\Models\airline\base\FlightModel;
use App\Models\CustomerModel;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model as BaseModel;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\SoftDeletes;

class PriceModel extends BaseModel
{
    use HasFactory, SoftDeletes;

    protected $table = 't_eml_price';

    protected $primaryKey = 'id';

    public $timestamps = true;

    const CREATED_AT = 'created_at';
    
    const UPDATED_AT = null;

    protected $guarded = [];

    protected $hidden = [
        'deleted_at',
    ];


    //创建人
    public function create_admin(): BelongsTo {
        return $this->belongsTo(AdminModel::class, 'created_admin_id');
    }

    //详情
    public function detail(): hasMany {
        return $this->HasMany(PriceDetailModel::class, 'price_id');
    }

    //航线
    public function route(): BelongsTo {
        return $this->belongsTo(RouteModel::class, 'route_id');
    }

    //航班
    public function flight(): BelongsTo {
        return $this->belongsTo(FlightModel::class, 'flight_id');
    }

    //币种
    public function currency(): BelongsTo {
        return $this->belongsTo(CurrencyModel::class, 'currency_id');
    }

    //客户
    public function customer(): BelongsTo
    {
        return $this->belongsTo(CustomerModel::class, 'customer_id');
    }

}
